﻿using System;
using System.Linq;
using System.Collections.Generic;
using INHollandair.Core.Models;
using INHollandair.Core.Repositories;

namespace INHollandair.Core.Services
{
    public class ProductService
    {
        private readonly ProductRepository _repo = new ProductRepository();

        public bool ProductExists(string userName)
        {
            return _repo.ProductRepo.Any(x => x.Name.Equals(userName));
        }
        public Product GetProductById(int id)
        {
            return _repo.ProductRepo.FirstOrDefault(x => x.Id.Equals(id));
        }
        public List<Product>GetProducts()
        {
            return _repo.ProductRepo.ToList();
        }
        public List<Product>GetProductsByDate(DateTime date)
        {
            return _repo.ProductRepo.Where(x => x.Date.Date.Equals(date.Date)).ToList();
        }
        public void InsertProduct(Product product)
        {
            _repo.InsertProduct(product);
        }
        public void UpdateProduct(Product product)
        {
            _repo.UpdateProduct(product);
        }
        public void RemoveProduct(Product product)
        {
            _repo.RemoveProduct(product);
        }

        public void InsertProducts(List<Product> products)
        {
            _repo.InsertProducts(products);
        }
        public void UpdateProducts(List<Product> products)
        {
            _repo.UpdateProducts(products);
        }
        public void RemoveProducts(List<Product> products)
        {
            _repo.RemoveProducts(products);
        }
    }
}
